import request from '@/utils/request'

export interface AttrValueData {
  id?: number,
  valueName: string,
  attrId: number | undefined,
  isEdit?:boolean
}

export type AttrData = {
  id?: number,
  attrName:string,
  categoryId: number | string,
  categoryLevel: number,
  attrValueList: AttrValueData[],
  attrIdValueId?:string
}

export default {
  /**
   * @description 获取所有的列表
   * @param category1Id 一级分类的某个id
   * @param category2Id 二级分类的某个id
   * @param category3Id 三级分类的某个id
   * @returns Promise<AttrData[]>
   */
  getList(category1Id:number,category2Id:number,category3Id:number){
    return request.get<any,AttrData[]>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
  },



  /**
   * @description 删除某个列表对象
   * @param attrId 某个列表对象的id
   * @returns Promise<null>
   */
  delete(attrId:number){
    return request.delete<any,null>(`/admin/product/deleteAttr/${attrId}`)
  },


  

  /**
   * @description 增加或修改某个列表对象
   * @param attr 列表对象
   * @returns Promise<null>
   */
  addOrUpdate(attr:AttrData){
    return request.post<any,null>('/admin/product/saveAttrInfo',attr)
  }
}